package com.dashu.device.service;

import com.dashu.base.utils.CopyUtil;
import com.dashu.device.dto.attendance.AttendanceGroupDTO;
import com.dashu.device.model.AttendanceGroup;
import com.dashu.device.model.QAttendanceGroup;
import com.querydsl.core.BooleanBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Slf4j
@Service
public class AttendanceGroupService extends DataService {

    @Autowired
    private CompanyTeacherService companyTeacherService;
    @Autowired
    private CompanyPersonalService companyPersonalService;


    public List<AttendanceGroupDTO> findAttendanceGroup(long attendancekRuleId) {
        QAttendanceGroup qAttendanceGroup = QAttendanceGroup.attendanceGroup;
        BooleanBuilder booleanBuilder = new BooleanBuilder();
        booleanBuilder.and(qAttendanceGroup.ruleId.eq(attendancekRuleId));
        List<AttendanceGroup> attendanceGroups =
                queryFactory
                        .select(qAttendanceGroup)
                        .from(qAttendanceGroup)
                        .where(booleanBuilder.getValue())
                        .fetch();
        List<AttendanceGroupDTO> attendanceGroupDTOS = CopyUtil.copyList(attendanceGroups, AttendanceGroupDTO.class);
        return attendanceGroupDTOS;

    }

}
